<template>
    <view class="content">
        <view class="u-p-b-20">
            <u-search placeholder="请输入名称" v-model="keyword" :show-action="false" bg-color="#fff" @search="doSearch"></u-search>
        </view>
        
        <view class="item" v-for="(item,index) in list" :key='index'>
            <view >试卷名称：{{item.title}}</view>
            <view class="u-p-t-10">楼盘名称：{{item.name}}</view>
            <view class="btns">
                <view class="pm-btn" @click="$gTo('/staff/pages/commissioner/test-rank?id='+ item.id)">查看排名</view>
                <view class="xq-btn" @click="$gTo('/staff/pages/commissioner/test-details?id='+ item.id)">查看详情</view>
            </view>
        </view>
        
        <!-- <view style="text-align: center;padding: 50upx 0;color: #999;font-size: 24rpx;" v-if="list.length == 0">暂无相关信息</view> -->
        <view style="height: 94rpx;padding-top: 30rpx;">
            <u-loadmore :status="status" v-if="status != 'loadmore'" />
        </view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                status: 'loadmore', //是否显示没有更多了
                page: 1,
                list: [], 
                keyword: '',
                type: 1,
            }
        },
        onLoad() {
            // uni.setNavigationBarTitle({
            // 	title:'项目驻场'
            // })
            
        },
        onShow() {
            this.page = 1
            this.list = []
            this.status = 'loadmore'
            this.getList()
        },
        onReachBottom() {
        	if(this.page == 1){return}
        	this.getList()
        },
        methods: {
            doSearch() {
                this.page = 1
                this.list = []
                this.status = 'loadmore'
                this.getList()
            },
            
            // 获取列表
            getList() {
            	if (this.status == 'nomore') return;
            	this.status = 'loading';
            	this.$ajax('question_activity', {
            		user_token: this.$getSync('userToken'),
                    name: this.keyword,
            		page: this.page,
            		limit: 10,
            	}).then(ret => {
            		if (ret.success == 1000) {
                        // this.list = ret.detail.activity
            			if (ret.detail && ret.detail.activity && ret.detail.activity.length > 0) {
            				this.list = this.list.concat(ret.detail.activity);
            				this.page++;
            				this.status = 'loadmore'
            			} else {
            				this.status = 'nomore'
            			}
            		} else {
            			this.$toast(ret.msg);
            		}
            	});
            },
        },
    }
</script>

<style lang="scss">
    page {
        background: #f5f5f5;
    }
    .content{
        padding: 20rpx;
    }
    .item{
        background-color: #fff;
        border-radius: 20rpx;
        padding: 30rpx 25rpx;
        margin-bottom: 20rpx;
        font-size: 24rpx;
    }
    .btns{
        display: flex;
        justify-content: flex-end;
        align-items: center;
        padding-top: 10rpx;
    }
    .pm-btn{
        font-size: 26rpx;
        padding: 12rpx 30rpx;
        border-radius: 50rpx;
        background-color: #00a1e9;
        color: #fff;
        margin-right: 15rpx;
    }
    .xq-btn{
        font-size: 26rpx;
        padding: 12rpx 30rpx;
        border-radius: 50rpx;
        background-color: #f0f0f0;
    }
    
    
</style>

